package com.smartgame.objects;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.smartgame.util.Assets;
import com.smartgame.util.Constants;
import com.smartgame.util.GdxUtil;

public class Background extends AbstractObject {

	private TextureRegion regBackground;

	public Background() {
		initObject();
	}

	public void initObject() {
		regBackground = Assets.instance.backgroud.reg;

		// fill to whole screen
		dimension.set(GdxUtil.getViewPortWidth(), Constants.VIEWPORT_HEIGHT);
		position.set(- dimension.x / 2, - dimension.y / 2);
		
		// Center image on game object
		origin.set(dimension.x / 2, dimension.y / 2);
	};

	@Override
	public void update(float deltaTime) {
		super.update(deltaTime);
		
		// special update goes here!
	}

	@Override
	public void render(SpriteBatch batch) {
		// Draw first
		float repeatX = 0;
		batch.draw(regBackground.getTexture(),
				position.x + repeatX, position.y,
				origin.x, origin.y,
				dimension.x, dimension.y,
				scale.x, scale.y,
				rotation,
				regBackground.getRegionX(), regBackground.getRegionY(),
				regBackground.getRegionWidth(), regBackground.getRegionHeight(),
				false, false);
		repeatX += dimension.x;
		
		// Draw second
		batch.draw(regBackground.getTexture(),
				position.x + repeatX, position.y,
				origin.x, origin.y,
				dimension.x, dimension.y,
				scale.x, scale.y,
				rotation,
				regBackground.getRegionX(), regBackground.getRegionY(),
				regBackground.getRegionWidth(), regBackground.getRegionHeight(),
				false, false);
		repeatX += dimension.x;
	}

	@Override
	public void reset() {
		
	}

}
